@echo off

setlocal

:: show the tips
echo ==========================================
echo wellcome to use swg command tool
echo this is the arguments of this tool:
echo 1. name or -n=[name]: the folder name(the name of the target project)
echo 2. dir or -d=[dir]: the folder to write to(start with ./)
echo 3. writer or -w=[writer]: the name of the writer(default is ts+axios)
echo 4. offline or -o=[isOffLine]: use local file(use the file of this project's sources folder)
echo 5. user or -u=[user]: the swagger.json file`s visitor name of BasicAuthToken (ignored with offline)
echo 6. pass or -p=[pass]: the swagger.json file`s visitor password of BasicAuthToken (ignored with offline)
echo 7. addr or -a=[addr]: the path of the swagger.json file(net url with online, relative path with offline)
echo ==========================================
echo the writers: js+axios, js+fetch, ts+axios, ts+fetch, flutter+dio
echo ==========================================
echo example: swg -n="test" -d="./api" -w="ts+axios" -u="swagger" -p="123456" -a="http://localhost/swagger/v1"
echo ==========================================
:: get the command
:input
set /p cmdStr=please enter your command: 

:: get the cmd name and parms
for /f "tokens=1* delims= " %%A in ("%cmdStr%") do (
    set cmdName=%%A
    set cmdArgs=%%B
)

:: check cmd name is swg
if /i "%cmdName%"=="swg" (
    :: excute the cmd with parms
    node ./lib/index.js %cmdArgs%
    goto input
) else (
    :: cmd name is not swg
    echo The command "%cmdName%" does not exist. Please try again.
    goto input
)

pause